var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("UIBase"),
    s = t("UIConfig"),
    c = t("UIManager"),
    p = t("GameEm"),
    l = cc._decorator,
    d = l.ccclass,
    u =
        (l.property,
        l.menu,
        (function (t) {
            i(e, t);
            function e() {
                return (null !== t && t.apply(this, arguments)) || this;
            }
            e.prototype._onUplevelTouchEnd = function () {
                QAudio.play(QAudio.ui_button);
                var t = this.ui_data.id,
                    e = (this.ui_data.typeIndex, GameDataValue.getEquipData(t)),
                    o = CacheDataManager.getCostumeup()[e.id],
                    a = CacheDataManager.getCostumeLvData(o.quality, e.lv).up_diamond || 0;
                a = Math.max(Math.floor(a), 0);
                var i = GameDataValue.getPropCount(p.PropKind.zhuanshi);
                i >= a &&
                    a > 0 &&
                    c.default.open(s.UIID.UIUseZs, {
                        cost: a,
                        cb: function () {
                            GameDataValue.upExpEquip(t);
                            GameDataValue.setPropCount(p.PropKind.zhuanshi, i - a);
                            CacheDataManager.updateCostDataView = !0;
                            var o = {resId: "" + e.id, count: a, type: 1, tip: "装备升级", tip2: ""};
                            PayData.addLog(o.resId, o.count, o.type, [], o.tip, o.tip2);
                        }
                    });
                CacheDataManager.updateCostDataView = !0;
            };
            e.prototype._onResetCostTouchEnd = function () {
                var t = this.ui_data.id,
                    e = (this.ui_data.typeIndex, GameDataValue.getEquipData(t)),
                    o = CacheDataManager.getCostumeup()[e.id],
                    a = CacheDataManager.getCostumeLvData(o.quality, e.lv).back_diamond || 0;
                a > 0 &&
                    c.default.open(s.UIID.UIResetLevelTip, {
                        count: a,
                        cb: function () {
                            GameDataValue.resetEquipLv(t);
                            CacheDataManager.updateCostDataView = !0;
                        }
                    });
            };
            e.prototype.updateBtnCost = function () {
                var t = this.ui_data.id,
                    e = GameDataValue.getEquipData(t),
                    o = CacheDataManager.getCostumeup()[e.id],
                    a = CacheDataManager.getCostumeLvData(o.quality, e.lv),
                    i = a.up_diamond || 0;
                i = Math.max(Math.floor(i), 0);
                var n = GameDataValue.getPropCount(p.PropKind.zhuanshi);
                this._uplevelLab.$Label.string = "" + i;
                this._uplevel.$Button.interactable = n >= i && i > 0;
                this.setRender(this._uplevel, this._uplevel.$Button.interactable);
                var r = a.back_diamond || 0;
                this.setRender(this._resetCost, r > 0);
            };
            e.prototype.setRender = function (t, e) {
                for (var o = t.getComponentsInChildren(cc.RenderComponent), a = 0; a < o.length; a++)
                    CacheDataManager.setSpriteMat(o[a], e);
            };
            e.prototype._onWearTouchEnd = function () {
                QAudio.play(QAudio.ui_button);
                if (GameDataValue.getWearEquip(this.ui_data.typeIndex) == this.ui_data.id)
                    GameDataValue.wearEquipId("", this.ui_data.typeIndex);
                else {
                    GameDataValue.wearEquipId(this.ui_data.id, this.ui_data.typeIndex);
                    this.sendWearData();
                }
                this.updateView();
                this.scheduleOnce(function () {
                    if (!GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][5])) {
                        GuildCache.checkKey = GuildCache.oncecheckId[2][5];
                        GuildCache.overOnceGuid(GuildCache.oncecheckId[2][5]);
                        GuildCache.openGuildView();
                    }
                }, 0.1);
            };
            e.prototype.sendWearData = function () {
                var t = this.ui_data.id,
                    e = GameDataValue.getEquipData(t),
                    o = CacheDataManager.getCostumeup();
                if (o[e.id])
                    switch (o[e.id].quality + "") {
                        case "1":
                            QReport.send("5001");
                            break;
                        case "2":
                            QReport.send("5002");
                            break;
                        case "3":
                            QReport.send("5003");
                    }
            };
            e.prototype.checkBtn = function () {
                var t = GameDataValue.getWearEquip(this.ui_data.typeIndex) == this.ui_data.id;
                this._wearLab.$Label.string = t ? "脱下" : "穿戴";
                this.updateBtnCost();
            };
            e.prototype.onShowEnd = function () {
                this.updateView();
                EVUIEffView.on(EVUIEffView.checkCostUI, this.updateView.bind(this), this);
                this.updateBtnCost();
                if (!GuildCache.isOverOnceGuid(GuildCache.oncecheckId[2][4])) {
                    GuildCache.checkKey = GuildCache.oncecheckId[2][4];
                    GuildCache.overOnceGuid(GuildCache.oncecheckId[2][4]);
                    GuildCache.openGuildView();
                }
            };
            e.prototype.updateView = function () {
                var t = this.ui_data.id,
                    e = GameDataValue.getEquipData(t),
                    o = CacheDataManager.getCostumeup(),
                    a = CacheDataManager.getCostume();
                if (o[e.id]) {
                    var i = o[e.id],
                        n = a[i.costume_id],
                        r = i.quality;
                    this._zhuanbeiName.$Label.string = CacheDataManager.getEquipName(e.id);
                    SpriteView.setQualityName(r, this._rateType.$Label);
                    SpriteView.setQualityBgLineColor(r, this._rateType);
                    var s = this._boxItem.$BoxItem;
                    s.nodeKindItem.setTypeKind(n.type, r);
                    var c = "lv." + e.lv + "/" + CacheDataManager.getQualityMaxLv(r);
                    s.levelLab.string = "";
                    this._detailLv.$Label.string = c;
                    s.resetView();
                    SpriteView.setTaskSprite(s.iconSprite, CacheDataManager.getEquipCostumeUpToIcon(i));
                    s.setQualityData(r);
                    this._detail1.$Label.string = "+" + CacheDataManager.getQualityLevelAdd(r, e.lv) + "%";
                    var p = CacheDataManager.getQualityLevelAdd(r, e.lv + 1);
                    this._detail2.$Label.string = "+" + p + "%";
                    this._allUnlockTipManagerCom.$AllUnlockTipManagerCom.setCustomer(e.id, e.lv);
                }
                this.checkBtn();
            };
            e.prototype.clickWear = function () {
                this._onWearTouchEnd();
            };
            e.prototype.onCloseStart = function () {
                QAudio.play(QAudio.ui_button);
                EVUIEffView.offTarget(this);
                EVUIEffView.emit(EVUIEffView.updateSkillTaskItem);
            };
            return n([d], e);
        })(r.default));
o.default = u;
